package gov.ccswj.modules.bdbusiness.controller;

import java.util.List;
import java.util.Map;

import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import gov.ccswj.modules.bdbusiness.entity.ANmEntity;
import gov.ccswj.modules.bdbusiness.service.ANmService;
import gov.ccswj.common.utils.PageUtils;
import gov.ccswj.common.utils.Query;
import gov.ccswj.common.utils.R;




/**
 * 
 * 
 * @author KY.Cheng
 * @email ********@gmail.com
 * @date 2017-11-29 14:35:49
 */
@RestController
@RequestMapping("/bdbusiness/anm")
public class ANmController {
	@Autowired
	private ANmService aNmService;
	
	/**
	 * 列表
	 */
	@RequestMapping("/list")
	@RequiresPermissions("bdbusiness:anm:list")
	public R list(@RequestParam Map<String, Object> params){
		//查询列表数据
        Query query = new Query(params);

		List<ANmEntity> aNmList = aNmService.queryList(query);
		int total = aNmService.queryTotal(query);
		
		PageUtils pageUtil = new PageUtils(aNmList, total, query.getLimit(), query.getPage());
		
		return R.ok().put("page", pageUtil);
	}
	
	
	/**
	 * 信息
	 */
	@RequestMapping("/info/{cityId}")
	@RequiresPermissions("bdbusiness:anm:info")
	public R info(@PathVariable("cityId") Integer cityId){
		ANmEntity aNm = aNmService.queryObject(cityId);
		
		return R.ok().put("aNm", aNm);
	}
	
	/**
	 * 保存
	 */
	@RequestMapping("/save")
	@RequiresPermissions("bdbusiness:anm:save")
	public R save(@RequestBody ANmEntity aNm){
		aNmService.save(aNm);
		
		return R.ok();
	}
	
	/**
	 * 修改
	 */
	@RequestMapping("/update")
	@RequiresPermissions("bdbusiness:anm:update")
	public R update(@RequestBody ANmEntity aNm){
		aNmService.update(aNm);
		
		return R.ok();
	}
	
	/**
	 * 删除
	 */
	@RequestMapping("/delete")
	@RequiresPermissions("bdbusiness:anm:delete")
	public R delete(@RequestBody Integer[] cityIds){
		aNmService.deleteBatch(cityIds);
		
		return R.ok();
	}
	
}
